package Euler7;

import java.util.LinkedList;

public class PrimeFind {

	public static void main(String[] args) {
		LinkedList<Integer> primes = getPrimes(150000);
		System.out.println(primes.get(10000));
	}

	public static LinkedList<Integer> getPrimes(int max)
	{
		LinkedList<Integer> primes = new LinkedList<Integer>();
		
		//Add 2 as prime.
		primes.add(2);
		
		for (int i = 3; i < max; i+=2)
		{
			if(isPrime(i))
			{
				primes.add(i);
			}
		}
		
		return primes;
	}
	
	public static boolean isPrime(int num)
	{
		if(num < 1)
		{
			return false;
		}
		else if(num == 1) 
		{
			return true;
		}
		
		for(int i = 2; i <= (num/2); i++)
		{
			if(num % i == 0)
			{
				return false;
			}
		}
		
		return true;
	}
}
